from mindquantum import Circuit, Simulator
from mindquantum.core.gates import H, X
from mindquantum.utils import generate_key_value

def run_bell_state_simulator():
    """ Define a phi plus bell state using MindQuantum, simulate it with 1000 shots and return the counts dictionary.
    """
    bell = Circuit()
    bell += H.on(0)
    bell += X.on(1, 0)
    sim = Simulator('mqvector', 2)
    result = sim.sampling(bell, shots=1000)
    return result

def check(candidate):
    result = candidate()
    assert isinstance(result, dict)
    assert result.keys() == {"00", "11"}
    assert 0.4 < (result["00"] / sum(result.values())) < 0.6

    print("OK")

if __name__ == '__main__':
    check(run_bell_state_simulator)